function FontInfo(pdDoc, imgPath){
	this.id=null;//对象ID
	this.family=null;
	this.w=null;//宽
	this.h=null;//高
	this.escapement=null;
	this.orientation=null;//方向
	this.italic=null;//斜体
	this.underline=null;//下划线
	this.strickOut=null;
	this.charSet=null;//字符集
	this.pitch=null;
	this.fontname=null;
	this.fontSize=null;//字休大小
	this.oblique=null;//斜体
	this.bold=null;//
	this.fontFace=null;
	this.fontFaceUrl=null; 
	this.isStandard = null;
	this.isEmbedded = null;
	//this.fontFamily = null;
	this.fontType = null;
	this.fontType3Info = null;
	this.isReplaceFont = 0;
	
	this.m_bCJK = 0;
	this.m_bVert = 0;
	this.m_Weight = 0;
    this.m_bValide = true;
    
    this.m_bSubst = false;
    this.m_SubstFamily = null;
    this.m_bSubstItalic = null;
    this.m_nSubstWeight = 400;
    this.m_bSustofCJK = null;
    this.m_bItalicCJK = null;
    this.m_nWeightCJK = 0;

    this.m_pdDoc = pdDoc;
    this.m_imgPath = imgPath;
    
	
	this.SetFontType3Info = function(fontType3Info){
		this.fontType3Info = fontType3Info;
	}
	
	this.GetFontType3Info = function(){
		return this.fontType3Info;
	}
	
	this.SetFontType = function(fontType){
		this.fontType = fontType;
	}
	
	this.GetFontType = function(){
		return this.fontType;
	}
	
	this.setIsStandard = function(isStandard){
		this.isStandard = isStandard;
	}
	this.SetFontFace=function(fontFace){
		this.fontFace=fontFace;
	}
	this.GetFontFace=function(){
		return this.fontFace;
	}
	this.SetFontFaceUrl=function(fontFaceUrl){
		this.fontFaceUrl=fontFaceUrl;
	}
	this.GetFontFaceUrl=function(){
		return this.fontFaceUrl;
	}
	
	this.SetOblique=function(oblique){
		this.oblique=oblique;
	}
	this.GetOblique=function(){
		return this.oblique;
	}
	this.SetBold=function(bold){
		this.bold=bold;
	}
	this.GetBold=function(){
		return this.bold;
	}
	this.fontPdf2Html=function(font_name){//pdf转html
		font_name=font_name.replaceAll(" ", "");

		var font_pdf=null;
		for(var key in stdFontMap){   
			if(stdFontMap[key]==font_name){
				font_pdf=key;
				break;
			}
		}
		if(font_pdf==null){
			for(var key in nonStdFontMap){   
				if(nonStdFontMap[key]==font_name){
					font_pdf=key;
					break;
				}
			}
		}
		if(font_pdf==null){
			return null;
		}else{
			this.font_split(font_pdf);
		}
	}
	this.fontHtml2Pdf=function(font_name){//html转pdf
		var font_html=stdFontMap.font_name;
		if(font_html==undefined && font_html==null){
			font_html=nonStdFontMap.font_name;
		}
		fontInfo.SetFamily(font_html);
		
	}
	this.font_split=function(font){
		var fontInfo=this;
		var is_valid=font.indexOf("-");
		if(is_valid!=-1){
			var temp=font.split("-")[1];
			switch(temp.toLowerCase()){
			case "bold": 
				fontInfo.SetBold(1);
				break; 
			case "boldoblique": 
				fontInfo.SetBold(1);
				fontInfo.SetOblique(1);
				break; 
			case "italic": 
				fontInfo.SetItalic(1);
				break; 
			case "bolditalic": 
				fontInfo.SetBold(1);
				fontInfo.SetItalic(1);
				break; 
			case "oblique": 
				fontInfo.SetOblique(1);
				break; 
			}
			font=font.split("-")[0];
		}
		return font;
	}

	this.ParseJson = function (ArrayData) {
	    //var fontInfo = this;
	    if (ArrayData.length == 0) return;
	    this.SetId(ArrayData[0]);
	    this.SetFamily(ArrayData[1]);
	    this.SetFontname(ArrayData[2]);
	    this.isEmbedded = ArrayData[8];
	    this.SetFontFace(ArrayData[11]);
	    this.SetFontFaceUrl(ArrayData[12]);
	    this.SetW(ArrayData[3]);
	    this.SetH(ArrayData[4]);
	    this.SetEscapement(ArrayData[5]);
	    this.SetOrientation(ArrayData[6]);
	    this.SetItalic(ArrayData[7]);
	    this.SetCharSet(ArrayData[9]);
	    this.setIsStandard(ArrayData[10]);
	    this.SetFontType(ArrayData[13]);
	    if (3 === ArrayData[13]) {
	        var type3Info = new Type3FontInfo();
	        type3Info.parseJson(ArrayData[14]);
	        this.fontType3Info = type3Info;
	    }
	}

	this.ParseFromBin = function (rd) {

	    this.id = rd.readUint16();
	    var nFamilyLen = rd.readByte();
	    this.family = rd.readString(nFamilyLen);
	    var nNameLen = rd.readByte();
	    this.fontname = rd.readString(nNameLen);
	    this.italic = rd.readByte();
	    this.isEmbedded = rd.readByte();
	    this.isStandard = rd.readByte();
	    this.m_bCJK = rd.readByte();
	    this.m_bVert = rd.readByte();
	    this.m_Weight = rd.readUint16();
	    this.charSet = rd.readByte();
	    var nFxNameLen = rd.readByte();
	    this.fontFace = rd.readString(nFxNameLen);
        
	    this.m_bSubst = rd.readByte();
	    if (1 == this.m_bSubst) {
	        var nSubstFamilyLen = rd.readByte();
	        this.m_SubstFamily = rd.readString(nSubstFamilyLen);
	        this.m_bSubstItalic = rd.readByte();
	        this.m_nSubstWeight = rd.readUint16();
	        this.m_bSustofCJK = rd.readByte();
	        this.m_bItalicCJK = rd.readByte();
	        this.m_nWeightCJK = rd.readUint16();
	    }
        
	    
	    this.fontType = rd.readByte();
	    if (rd.readByte()) {
	        var type3Info = new Type3FontInfo(this.m_pdDoc, this.m_imgPath);
	        type3Info.ParseFromBin(rd);
	        this.fontType3Info = type3Info;
	    }

	}
	
	
	this.VerificationParseJson=function(ArrayData){
		if(this.GetFontFace() == ArrayData[11])return true;
		else return false;
	}
   this.CreateRanNum=function(){//创建fontInfo中唯一随机数
		var fontInfoId=generateMixed(4);
		var flag=true;
		do{
			flag=this.GetFontInfoByID(fontInfoId)==null?false:true;
		}while(flag);
		return fontInfoId;
	}
	this.SetFontSize=function(fontSize){
		this.fontSize=fontSize;
	}
	this.GetFontSize=function(){
		return this.fontSize;
	}
	this.SetFontname=function(fontname){
		this.fontname=fontname;
	}
	this.GetFontname=function(){
		return this.fontname;
	}
	this.SetPitch=function(pitch){
		this.pitch=pitch;
	}
	this.GetPitch=function(){
		return this.pitch;
	}
	this.SetCharSet=function(charSet){
		this.charSet=charSet;
	}
	this.GetCharSet=function(){
		return this.charSet;
	}
	this.SetStrickOut=function(strickOut){
		this.strickOut=strickOut;
	}
	this.GetStrickOut=function(){
		return this.strickOut;
	}
	this.SetUnderline=function(underline){
		this.underline=underline;
	}
	this.GetUnderline=function(){
		return this.underline;
	}
	this.SetItalic=function(italic){
		this.italic=italic;
	}
	this.GetItalic=function(){
		return this.italic;
	}
	this.SetOrientation=function(orientation){
		this.orientation=orientation;
	}
	this.GetOrientation=function(){
		return this.orientation;
	}
	this.SetEscapement=function(escapement){
		this.escapement=escapement;
	}
	this.GetEscapement=function(){
		return this.escapement;
	}
	this.SetH=function(h){
		this.h=h;
	}
	this.GetH=function(){
		return this.h;
	}
	this.SetW=function(w){
		this.w=w;
	}
	this.GetW=function(){
		return this.w;
	}
	this.SetFamily=function(family){
		this.family=family;
	}
	this.GetFamily=function(){
		return this.family;
	}
	this.SetId=function(id){
		this.id=id;
	}
	this.GetId=function(){
		return this.id;
	}
}

function generateMixed(n){
	var rnd="";
	for(var i=0;i<n;i++){
		rnd+=Math.floor(Math.random()*10);
	}
	return parseInt(rnd);
}

var baseFonts = [
"Courier", 
"Courier-Bold",
"Courier-BoldOblique",
"Courier-Oblique",
"Helvetica",
"Helvetica-Bold",
"Helvetica-BoldOblique",
"Helvetica-Oblique",
"Times-Roman",
"Times-Bold",
"Times-BoldItalic",
"Times-Italic",
"Symbol",
"ZapfDingbats",
"Foxit Sans MM",
"Foxit Serif MM"
];

